package com.linsen.core.log.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 登录日志类型
 *
 * @author zhaoyong
 * @date 2023/3/14
 */
@Getter
@AllArgsConstructor
public enum LoginType {

    LOGININ(1, "登录"),
    LOGINOUT(2, "退出"),
    ;

    @JsonValue
    private final Integer value;
    private final String desc;

    private static final Map<Integer, LoginType> VALUES = new HashMap<>();

    static {
        for (final LoginType loginType : LoginType.values()) {
            LoginType.VALUES.put(loginType.getValue(), loginType);
        }
    }

    @JsonCreator
    public static LoginType getByValue(Integer value) {
        return LoginType.VALUES.get(value);
    }
}
